package com.jxm.hutools;

import cn.hutool.core.convert.Convert;
import cn.hutool.core.lang.Filter;
import cn.hutool.core.map.MapUtil;
import org.junit.Test;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: jxm
 * @Description:
 * @Date: 2023-12-19 9:43
 * @Version: 1.0
 */
public class MapUtilTest {

    @Test
    public void test1(){
        Map<String, String> map = MapUtil.createMap(String.class);
        Map<Student, Student> map1 = MapUtil.createMap(Student.class);
        HashMap<String, Student> newHashMap = MapUtil.newHashMap();

    }

    @Test
    public void test2(){
        Map<String, String> map = MapUtil.newHashMap();
        map.put("a", "1");
        map.put("b", "2");
        map.put("c", "3");
        map.put("d", "4");
        Map<String, String> filter = MapUtil.filter(map, (Filter<Map.Entry<String, String>>) t -> Convert.toInt(t.getValue()) % 2 == 0);
        for (Map.Entry<String, String> entry : filter.entrySet()) {
            System.out.println(entry.getKey()+","+entry.getValue());
        }
    }

    class Student{
        private int age;
    }
}
